import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class Leitura {
    public static void main(String[] args) throws IOException {
        BufferedReader inputStream = null;
        PrintWriter outputStream = null;

        try {
            inputStream = 
                new BufferedReader(new FileReader("/home/drocha/desenvolvimento/SQL/src/CTU47465.RET"));
            outputStream = 
                new PrintWriter(new FileWriter("/home/drocha/desenvolvimento/SQL/src/characteroutput.txt"));

            String l;
            
            List<Registro> headers = new ArrayList<Registro>();
            headers.add(new Registro(1,7,6,""));
            headers.add(new Registro(8,15,8,""));
            headers.add(new Registro(16,21,6,""));
            headers.add(new Registro(22,71,50,""));
            headers.add(new Registro(72,75,4,""));
            headers.add(new Registro(76,76,1,""));
            headers.add(new Registro(1,7,6,""));
            headers.add(new Registro(1,7,6,""));
            headers.add(new Registro(77,87,11,""));
            headers.add(new Registro(88,88,1,""));
            headers.add(new Registro(89,97,9,""));
            headers.add(new Registro(98,105,8,""));
            headers.add(new Registro(106,114,9,""));
            headers.add(new Registro(115,122,8,""));
            headers.add(new Registro(123,124,2,""));
            headers.add(new Registro(125,133,9,""));
            headers.add(new Registro(134,174,41,""));
            headers.add(new Registro(175,177,3,""));
            headers.add(new Registro(178,181,4,""));
            headers.add(new Registro(182,189,8,""));
            headers.add(new Registro(190,209,20,""));
            headers.add(new Registro(210,210,1,""));
            headers.add(new Registro(211,216,6,""));
            headers.add(new Registro(217,222,6,""));
        
            Header header = new Header();
            
            while ((l = inputStream.readLine()) != null) {
            	for(Registro registro : headers){
            		registro.setValor(l.substring(registro.getPosInicial(), registro.getPosFinal()).trim());
            	}
            	break;
            }
            System.out.println(headers.toString());
        } finally {
            if (inputStream != null) {
                inputStream.close();
            }
            if (outputStream != null) {
                outputStream.close();
            }
        }
    }
}
